/*#include "metrics.h"

#include "script/scripthelper.h"
#include "script/write_lua.h"

#include "util/timer.h"				// log
#include "util/log.h"				// log
#include "util/common_macros.h"		// macros
#include "util/mmgr.h"		    
#include <cassert>

using namespace gameflow;
using namespace script;

Metrics& Metrics::Instance()
{
	static Metrics	Inst;
	return Inst;
}

Metrics::Metrics()
{

}

Metrics::~Metrics()
{

}

void		Metrics::Load(const std::string& File)
{
#ifdef  _TRACK_METRICS                
	LuaPlus::LuaState*	pScript = ScriptHelper::CreateLuaState();
	if (!ScriptHelper::DoFile(*pScript, File))
	{
		 LuaState::Destroy( pScript );
		return;
	} else
	{
		LuaPlus::LuaObject	Metrics = ScriptHelper::GetObj(*pScript, "Metrics");
		if (Metrics.IsTable())
		{
			int		Count = Metrics.GetTableCount();
			for (int i=0; i<Count; i++)
			{
				LuaPlus::LuaObject	Entry = Metrics.GetByIndex(i+1);
				if (Entry.IsTable())
				{
					MetricPackage* pKey = new MetricPackage();
					pKey->Key				= ScriptHelper::GetTableString(Entry, "Name", "");
					pKey->TotalSamples		= ScriptHelper::GetTableInt(Entry, "TotalSamples", 0);
					pKey->Total				= ScriptHelper::GetTableFloat(Entry, "Total", 0.0f);
					pKey->Min				= ScriptHelper::GetTableFloat(Entry, "Min", 0.0f);
					pKey->Max				= ScriptHelper::GetTableFloat(Entry, "Max", 0.0f);

					if (!pKey->Key.empty())
					{
						AddElement(pKey->Key, pKey);
					}
					else
					{
						UTIL_SAFE_DELETE(pKey);
					}
				}
			}
		}
	}
	LuaState::Destroy( pScript );
#endif
}

void		Metrics::Save(const std::string& File)
{
#ifdef  _TRACK_METRICS                
	WriteLua	ScriptFile;
	ScriptFile.Open(File);

	ScriptFile.StartTable("Metrics");

		for (ElementMap::iterator It = m_Set.begin(); It != m_Set.end(); It++)
		{
			//pCB(It->second, Data);
			ScriptFile.StartTable("");
				MetricPackage*	pData = It->second;

				float Total = pData->Total + pData->ThisTurn;
				int	TotalSamples = pData->TotalSamples  + pData->SamplesThisTurn;
					
				ScriptFile.WritePair("Name",			pData->Key);
				ScriptFile.WritePair("Total",			Total);
				ScriptFile.WritePair("ThisTurn",		pData->ThisTurn);
				ScriptFile.WritePair("Min",				pData->Min);
				ScriptFile.WritePair("Max",				pData->Max);
				ScriptFile.WritePair("MeanThisTurn",	pData->ThisTurn/(float)pData->SamplesThisTurn );
				ScriptFile.WritePair("TotalMean",		Total/(float)TotalSamples);
				ScriptFile.WritePair("SamplesThisTurn", pData->SamplesThisTurn);
				ScriptFile.WritePair("TotalSamples",	TotalSamples);
			ScriptFile.CloseTable(true);
		}
	ScriptFile.CloseTable(false);
#endif
}

void		Metrics::ResetKey(const std::string& Key)
{
	MetricPackage* pKey = GetElement(Key);
	if (!pKey)
	{
		pKey = new MetricPackage();
		pKey->Key = Key;
		AddElement(Key, pKey);
	} else
	{
		pKey->Reset();
	}
}

void		Metrics::AccumulateKey(const std::string& Key, float Value)
{
	MetricPackage* pKey = GetElement(Key);
	if (!pKey)
	{
		pKey = new MetricPackage();
		pKey->Key = Key;
		AddElement(Key, pKey);
	}
	pKey->ThisTurn += Value;
	pKey->SamplesThisTurn++;
	pKey->TotalSamples++;

	if (Value < pKey->Min)
	{
		pKey->Min = Value;
	}
	if (Value > pKey->Max)
	{
		pKey->Max = Value;
	}
}

AutoMetric::AutoMetric(const std::string& Key)
{
	KeyID = Key;
	Start = TIMER().GetTimeStamp();
}
AutoMetric::~AutoMetric()
{
	float	End		= TIMER().GetTimeStamp();
	float	Delta	= End-Start;
	Metrics::Instance().AccumulateKey(KeyID, Delta);
}
*/